<html>

<head>
  <title></title>
</head>

<body>

	<form method=post>

    <center>
    <table border=1 width=50% cellpadding=10>
<?php

	include "kernel.php";
	include "adw_functions.php";

    if (!$_POST[squad]) {



	    $r = mysql_query("select * from squadrons where allsorties=0 order by id");


	    while ($res = mysql_fetch_assoc($r)) {

        		$fl = 0;

        		$fp_r = mysql_query("select * from pilots where squadronid='$res[id]'");

                while ($fp = mysql_fetch_assoc($fp_r)) {

                	$sort_r = mysql_query("select id from sorties where pilotid='$fp[id]'");

                    if (mysql_num_rows($sort_r)>0) $fl=1;

                }

				$plane = GetSquadPlane($res[id]);
				$plname = GetPlaneNameById($plane);

                if (!$fl)
					echo "<tr><td align=center>$res[tag] - [$plname ($plane)]</td><td align=center><input type=submit name=squad[$res[id]] value=\" Drop \"></td></tr>";
	    }

    }
    else {


	 	$sq = array_keys($_POST[squad]);
        $sq = $sq[0];

        $sq = GetSquadById($sq);

        $plane = GetSquadPlane($sq[id]);

        mysql_query("update reserv set busycount=busycount-$sq[maxpilots] where army='$sq[army]' and typeOf='$sq[typeOf]' and plane_id=$plane");
        mysql_query("update squadrons set isactive=0, lineid=0 where id='$sq[id]'");

        echo "<h2>Done.</h2>";

    }

?>

	</table>
    </center>

</body>

</html>